function connobj(conn) {

  if(conn!=null) { 
    if(conn.getAttribute("ServerIs")) { this.serverIs=conn.getAttribute("ServerIs"); }

    if(conn.getElementsByTagName("Port1").length>0) { this.p1=conn.getElementsByTagName("Port1")[0].childNodes[0].nodeValue; }
    if(conn.getElementsByTagName("MAC1").length>0) { this.mac1=conn.getElementsByTagName("MAC1")[0].childNodes[0].nodeValue; }
    if(conn.getElementsByTagName("IP1").length>0) { this.ip1=conn.getElementsByTagName("IP1")[0].childNodes[0].nodeValue; }
    
    if(conn.getElementsByTagName("Port2").length>0) { this.p2=conn.getElementsByTagName("Port2")[0].childNodes[0].nodeValue; }
    if(conn.getElementsByTagName("MAC2").length>0) { this.mac2=conn.getElementsByTagName("MAC2")[0].childNodes[0].nodeValue; }
    if(conn.getElementsByTagName("IP2").length>0) { this.ip2=conn.getElementsByTagName("IP2")[0].childNodes[0].nodeValue; }

    if(conn.getElementsByTagName("ServiceName").length>0) { this.servicename=conn.getElementsByTagName("ServiceName")[0].childNodes[0].nodeValue; }
    if(conn.getElementsByTagName("Proto").length>0) { this.proto=conn.getElementsByTagName("Proto"); }
    
    if(conn.getAttribute("Status")) { this.stat=conn.getAttribute("Status"); }
    if(conn.getAttribute("LastSeen")) { this.lastseen=conn.getAttribute("LastSeen"); }
    if(conn.getAttribute("toOutside")) { this.tooutside=conn.getAttribute("toOutside"); }
    if(conn.getElementsByTagName("Kbs").length>0) { this.kbs=conn.getElementsByTagName("Kbs")[0].childNodes[0].nodeValue; }
  }
};

function connlist() {

    this.connections = [];
    this.connsummary =  [];
    
    //Solo quelle attive o quelle open
    this.activeopen = true;

    this.add = function(obj) {
      this.connections.push(obj);
      
      var founded = false;
      for(i=0; i<this.connsummary.length; i++) {
	if(this.connsummary[i].serverIs==conn.serverIs && this.connsummary[i].ip1==conn.ip1 && this.connsummary[i].ip2==conn.ip2 && this.connsummary[i].servicename==conn.servicename) { founded = true; }
      }
      if (!founded) { this.connsummary.push(obj); }
      
    };

    this.getConnBetween = function(mac1, mac2,all) {

      if(all) { connections=this.connections; }
      else { connections=this.connsummary; }
      
      toreturn = [];

      for (var i=0; i<connections.length; i++) {
	if((connections[i].mac1==mac1 && connections[i].mac2==mac2) || (connections[i].mac1==mac2 && connections[i].mac2==mac1)) {
	  if(this.activeopen) {
	    if(connections[i].stat=="OPENED" || connections[i].stat=="ACTIVE") {
	      toreturn.push(connections[i]);
	    }
	  }
	  else { toreturn.push(connections[i]);  }
	}
      }
      return toreturn;
    };

    this.getConnOf = function(mac,all) {
      
      if(all) { connections=this.connections; }
      else { connections=this.connsummary; }
      
      toreturn = [];

      for (var i=0; i<connections.length; i++) {
	if(connections[i].mac2==mac || connections[i].mac1==mac) {
	  if(this.activeopen) {
	    if(connections[i].stat=="OPENED" || connections[i].stat=="ACTIVE") {
	      toreturn.push(connections[i]);
	    }
	  }
	  else { toreturn.push(connections[i]);  }
	  
	}
      }
      
      return toreturn;
    };


};